package edu.ynu.se.xiecheng.achitectureclass.controller;

import edu.ynu.se.xiecheng.achitectureclass.common.controller.LogicController;
import edu.ynu.se.xiecheng.achitectureclass.dao.ShopDao;
import edu.ynu.se.xiecheng.achitectureclass.entity.Item;
import edu.ynu.se.xiecheng.achitectureclass.entity.Shop;
import edu.ynu.se.xiecheng.achitectureclass.entity.ShopItem;
import edu.ynu.se.xiecheng.achitectureclass.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "shop实体的控制器")
@RestController
@RequestMapping("/shop")
public class ShopController extends LogicController<ShopService, ShopDao,Shop,Long> {
    public ShopController(@Autowired ShopService ss){
        super(ss);
    }
    @ApiOperation("门店创建商品")
    @GetMapping("/createShopItem/{shopId}/{itemId}/{price}")
    public Shop createShopItem(@PathVariable Long shopId, @PathVariable Long itemId , @PathVariable Double price){
        return getService().createShopItem(shopId,itemId, price);
    }

    @ApiOperation("门店上架商品")
    @GetMapping("/onShelf/{shopId}/{itemId}")
    public ShopItem onShelf(@PathVariable Long shopId, @PathVariable Long itemId){
        return getService().onShelf(shopId,itemId);
    }

    @ApiOperation("门店下架商品")
    @GetMapping("/offShelf/{shopId}/{itemId}")
    public ShopItem offShelfShopItem(@PathVariable Long shopId, @PathVariable Long itemId){
        return getService().offShelf(shopId,itemId);
    }

    @ApiOperation("展示所有商店")
    @GetMapping("/listShops")
    public List<Shop> listShops(){
        return getService().listShops();
    }

    @ApiOperation("展示可上架的商品")
    @GetMapping("/listAvailableItem/{businessId}")
    public List<Item> listAvailableItem(@PathVariable Long businessId){
        return getService().listAvailableItem(businessId);
    }

    @ApiOperation("展示已上架的商品")
    @GetMapping("/listOnShelfShopItem/{shopId}")
    public List<ShopItem> listOnShelfShopItem(@PathVariable Long shopId){
        return getService().listOnShelfShopItem(shopId);
    }
}
